package com.ruoyi.report.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.report.domain.RemindType;
import com.ruoyi.report.service.IRemindTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提醒类型Controller
 * 
 * @author ruoyi
 * @date 2023-09-26
 */
@RestController
@RequestMapping("/report/type")
public class RemindTypeController extends BaseController
{
    @Autowired
    private IRemindTypeService remindTypeService;

    /**
     * 查询提醒类型列表
     */
    @PreAuthorize("@ss.hasPermi('report:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(RemindType remindType)
    {
        startPage();
        List<RemindType> list = remindTypeService.selectRemindTypeList(remindType);
        return getDataTable(list);
    }

    /**
     * 导出提醒类型列表
     */
    @PreAuthorize("@ss.hasPermi('report:type:export')")
    @Log(title = "提醒类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RemindType remindType)
    {
        List<RemindType> list = remindTypeService.selectRemindTypeList(remindType);
        ExcelUtil<RemindType> util = new ExcelUtil<RemindType>(RemindType.class);
        util.exportExcel(response, list, "提醒类型数据");
    }

    /**
     * 获取提醒类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(remindTypeService.selectRemindTypeById(id));
    }

    /**
     * 新增提醒类型
     */
    @PreAuthorize("@ss.hasPermi('report:type:add')")
    @Log(title = "提醒类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RemindType remindType)
    {
        return toAjax(remindTypeService.insertRemindType(remindType));
    }

    /**
     * 修改提醒类型
     */
    @PreAuthorize("@ss.hasPermi('report:type:edit')")
    @Log(title = "提醒类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RemindType remindType)
    {
        return toAjax(remindTypeService.updateRemindType(remindType));
    }

    /**
     * 删除提醒类型
     */
    @PreAuthorize("@ss.hasPermi('report:type:remove')")
    @Log(title = "提醒类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(remindTypeService.deleteRemindTypeByIds(ids));
    }
}
